const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

module.exports = {
  formatTime: formatTime
}


var index = require('../datas/data_index.js')

function getData(url){
  return new Promise(function(resolve,reject){
    wx.request({
      url: url,
      data:{},
      header:{},
      success:function(res){
        console.log("success");
        resolve(res);
      },
      fail:function(res){
        reject(res);
        console.log("fail")
      }
    })
  })
}

function getDataLocal(dataType){
  var data=null;
  switch (dataType){
    case "index":data=index.index;break;
  }
  return data;
}

module.exports.getData = getData;
module.exports.getDataLocal = getDataLocal;